package com.common.www.bean.entity.auth;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.boot.base.jpa.domain.entity.NumberIdentityEntity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "auth_access")
public class AuthAccess extends NumberIdentityEntity {
    private static final long serialVersionUID = -3925162576114109165L;
    private String name;

    @Column(length = 1024)
    private String description;

    @JsonIgnoreProperties(value = {"authUsers", "authAccesses"})
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "auth_role_ref_access", joinColumns = @JoinColumn(name = "access_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
    private List<AuthRole> authRoles = new ArrayList<AuthRole>(0);

}
